﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for BaseView
/// </summary>
public class BaseView : NonSecuredBaseView
{
    public BaseView()
    {
        //PreLoad += BaseView_PreLoad;
        Load += new EventHandler(BaseView_Load);
    }
    protected void BaseView_PreLoad(object sender, EventArgs e)
    {
        MaintainScrollPositionOnPostBack = true;
        if (!IsPostBack)
        {
            if (!UserID.HasValue || string.IsNullOrEmpty(UserName) || !CompanyID.HasValue)
            {
                SignOut();
            }
        }
    }
    protected void BaseView_Load(object sender, EventArgs e)
    {
        MaintainScrollPositionOnPostBack = true;
        if (!IsPostBack)
        {
            if (!UserID.HasValue || string.IsNullOrEmpty(UserName) || !CompanyID.HasValue)
            {
                SignOut();
            }
        }
    }
    public void SignOut()
    {
        Session.Abandon();
        FormsAuthentication.SignOut();
        FormsAuthentication.RedirectToLoginPage();
        Response.End();
    }

  
}